
package cs.remoteapp;
/**
 * The Hello class to instantiate a Message object Hello.
 * It notifies the arrival of a new user in the chat system.
 * <br>
 * There are two types of Hello message:
 * <ul>
 * <li>Hello broadcast (destination IP address = broadcast address)
 * Message notification of a new connection.
 * <li>Hello P2P (destination IP address = user address): 
 * Response Message to know the users present.
 * </ul>
 * <p>
 * The object is serializable to be encapsulated in a UDP packet. 
 * @author      4INFO - A1
 * @version     1.0
 */
public class Hello extends Message {
	/**
	 * Serialization id
	 */
	private static final long serialVersionUID = 860939948385185868L;
	
	/**
	 * determines whether the message have been broadcasted
	 * Hello messages broadcasted denote a connection request while
	 * Hello messages which are not broadcasted denote an response to a connection 
	 * request
	 */
	private boolean isBroadcast;
	
	/**
	 * constructor
	 * @param username the sender username 
	 */
	public Hello(String username){
		super(username);
		
		/**
		 * false by default
		 */
		this.isBroadcast = false;
	}
	
	/**
	 * check whether this Hello message has been broadcasted
	 * @return true if this Hello message have been broadcasted and false otherwise
	 */
	public boolean isBroadcast() {
		return isBroadcast;
	}
	
	/**
	 * set broadcast 
	 * @param isBroadcast true if is the message is to be broadcast and false otherwise
	 */
	public void setBroadcast(boolean isBroadcast) {
		this.isBroadcast = isBroadcast;
	}

}
